package simple04;


import simple04.fruit.Apple;
import simple04.fruit.Banana;
import simple04.fruit.Orange;

public class FruitMeal {
    private Apple apple;
    private Banana banana;
    private Orange orange;
    private int discount;//折扣
    private int totalPrice; //总价

    public void setApple(Apple apple) {
        this.apple = apple;
    }

    public void setBanana(Banana banana) {
        this.banana = banana;
    }

    public void setOrange(Orange orange) {
        this.orange = orange;
    }

    public void setDiscount(int discount) {
        this.discount = discount;
    }

    public int getTotalPrice() {
        return totalPrice;
    }


    public  void  init(){
        if (null !=  apple){
            totalPrice += apple.price();
        }

        if (null != orange){
            totalPrice+= orange.price();
        }
        if (null != banana){
            totalPrice += banana.price();
        }
        if (totalPrice >0){
            totalPrice -= discount;
        }

    }
    public void showItems(){
        System.out.println("totalPrice:"+totalPrice);
    }
}
